package com.oaker.web.controller.hardWare;

import com.appleyk.core.ex.CommonException;
import com.appleyk.core.result.ResponseResult;
import com.appleyk.core.service.AServerInfos;
import com.oaker.system.service.impl.LicenseServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>服务器硬件信息获取API</p>
 *
 * @author appleyk
 * @version v1.0.0
 * @blob https://blog.csdn.net/appleyk
 * @date created on 10:30 下午 2020/8/21
 */
@RestController
@Api(tags = "获取机器码信息")
@RequestMapping("/license")
public class HardWareInfoController {

    @Resource
    private LicenseServiceImpl licenseService;

    /**
     * <p>获取服务器硬件信息</p>
     * @param osName 操作系统类型，如果为空则自动判断
     */
    @RequestMapping(value = "/getServerInfos",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    @ApiOperation(value="获取服务器硬件信息")
    public ResponseResult getServerInfos(@RequestParam(value = "osName",required = false)  @ApiParam(name="服务器类型",value="win：windows  linux: linux") String osName) {
        return ResponseResult.ok(AServerInfos.getServer(osName).getServerInfos());
    }

    @GetMapping("/info")
    @ApiOperation(value="获取证书信息")
    public ResponseResult getCertInfo() throws CommonException {

        return ResponseResult.ok(licenseService.getLicenseInfo());
    }


}
